﻿<Window x:Class="VolunteerHubAdapter.Views.SettingsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:t="clr-namespace:VolunteerHubAdapter"
             xmlns:Models="clr-namespace:VolunteerHubAdapter.Models"
             xmlns:Views="clr-namespace:VolunteerHubAdapter.Views"
             xmlns:XC="clr-namespace:Omatic.XceedControls;assembly=Omatic.XceedControls"
             mc:Ignorable="d" d:DesignWidth="300" SizeToContent="Height" AllowsTransparency="True" Width="450" Title="VolunteerHub Connection Information"
             WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Background="Transparent" >
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <Style TargetType="{x:Type Button}">
            <Setter Property="FocusVisualStyle">
                <Setter.Value>
                    <Style>
                        <Setter Property="Control.Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Rectangle Margin="2" SnapsToDevicePixels="True" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="Background" Value="#F7941E"/>
            <Setter Property="BorderBrush" Value="#FFC57515"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="TextElement.FontWeight" Value="Bold" />
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="6,3" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="border" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                            <Border>
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                        <GradientStop Offset="0" />
                                        <GradientStop Offset="1" Color="#4B000000" />
                                    </LinearGradientBrush>
                                </Border.Background>
                                <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsDefaulted" Value="True">
                                <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" TargetName="border" Value="#FFF79F36"/>
                                <Setter Property="BorderBrush" TargetName="border" Value="#FFC57E29"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Background" TargetName="border" Value="#FFFF8B00"/>
                                <Setter Property="BorderBrush" TargetName="border" Value="#FFAA6410"/>
                            </Trigger>
                            <Trigger Property="ToggleButton.IsChecked" Value="True">
                                <Setter Property="Background" TargetName="border" Value="#FFBCDDEE"/>
                                <Setter Property="BorderBrush" TargetName="border" Value="#FF245A83"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Background" TargetName="border" Value="#FFF4F4F4"/>
                                <Setter Property="BorderBrush" TargetName="border" Value="#FFADB2B5"/>
                                <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="#FF838383"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <DrawingBrush x:Key="HelpIcon" Stretch="Uniform">
            <DrawingBrush.Drawing>
                <DrawingGroup>
                    <DrawingGroup.Children>
                        <GeometryDrawing Geometry="F1 M 14.4375,1C 21.8588,1 27.875,7.01617 27.875,14.4375C 27.875,21.8588 21.8588,27.875 14.4375,27.875C 7.01617,27.875 1,21.8588 1,14.4375C 1,7.01618 7.01617,1 14.4375,1 Z ">
                            <GeometryDrawing.Pen>
                                <Pen Thickness="2" LineJoin="Round" Brush="#0350a2"/>
                            </GeometryDrawing.Pen>
                        </GeometryDrawing>
                        <GeometryDrawing Brush="#0350a2" Geometry="F1 M 16.36,19.1175L 12.44,19.1175C 12.4312,18.6158 12.4269,18.311 12.4269,18.2031C 12.4269,17.0715 12.6237,16.141 13.0175,15.4119C 13.4112,14.6827 14.2002,13.8624 15.3844,12.9509C 16.5685,12.0395 17.2758,11.4423 17.5062,11.1594C 17.8621,10.7131 18.04,10.2217 18.04,9.685C 18.04,8.9675 17.7578,8.35355 17.1934,7.84313C 16.6291,7.33271 15.8685,7.07751 14.9119,7.07751C 13.9902,7.07751 13.2195,7.33125 12.5997,7.83875C 11.9799,8.34625 11.5533,9.11917 11.32,10.1575L 7.39999,9.8775C 7.50208,8.24125 8.20572,6.85219 9.51093,5.71032C 10.8161,4.56844 12.5304,3.99751 14.6537,3.99751C 16.885,3.99751 18.6605,4.57792 19.9803,5.73875C 21.3001,6.89959 21.96,8.25146 21.96,9.79438C 21.96,10.6431 21.7194,11.4452 21.2381,12.2006C 20.7569,12.956 19.7273,13.9856 18.1494,15.2894C 17.3327,15.9631 16.8259,16.5056 16.6291,16.9169C 16.4322,17.3281 16.3425,18.0617 16.36,19.1175 Z M 12.44,24.4375L 12.44,20.5175L 16.36,20.5175L 16.36,24.4375L 12.44,24.4375 Z "/>
                    </DrawingGroup.Children>
                </DrawingGroup>
            </DrawingBrush.Drawing>
        </DrawingBrush>
    </Window.Resources>
    <Border>
        <Border.Effect>
            <DropShadowEffect ShadowDepth="3" Color="#FF707070" />
        </Border.Effect>
        <Border Background="White" Margin="5" BorderThickness="1" BorderBrush="#FFA8A8A8">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50" />
                    <RowDefinition />
                    <!--<RowDefinition Height="Auto" />-->
                </Grid.RowDefinitions>
                <Border MouseMove="Border_MouseMove" Background="Transparent">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Image Source="/VolunteerHubAdapter;component/Resources/VolunteerHub.png" HorizontalAlignment="Left" Margin="5,3,0,0" />
                        <Button Grid.Column="1" Margin="0,5,5,2" HorizontalAlignment="Right" VerticalAlignment="Center" Height="18" Width="18" Command="{Binding HelpCommand}">
                            <Button.Template>
                                <ControlTemplate>
                                    <Border Cursor="Hand" Background="{StaticResource HelpIcon}"></Border>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                    </Grid>
                </Border>
                <Border Grid.Row="1" Margin="5" BorderThickness="1" Background="#052F70" BorderBrush="#FF266587">
                    <Grid Margin="4,4,4,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="35"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="185"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Label VerticalAlignment="Center" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" Foreground="White">VolunteerHub Organization URL:</Label>
                        <TextBox VerticalAlignment="Center" Grid.Column="1" Grid.Row="0" Margin="2" Text="{Binding Path=URL,Mode=TwoWay}"/>
                        <Label VerticalAlignment="Center" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Foreground="White">User:</Label>
                        <TextBox VerticalAlignment="Center" Grid.Column="1" Grid.Row="1" Margin="2" Text="{Binding Path=User,Mode=TwoWay}"/>
                        <Label VerticalAlignment="Center" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" Foreground="White">Password:</Label>
                        <PasswordBox VerticalAlignment="Center" Grid.Column="1" Grid.Row="2" Margin="2,0,2,0"
                            t:PasswordBoxAssistant.BindPassword="true"  t:PasswordBoxAssistant.BoundPassword="{Binding Path=Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                        
                        <Label VerticalAlignment="Center" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right" Foreground="White" Visibility="{Binding ShowDates,Converter={StaticResource BooleanToVisibilityConverter}}">Registration Start Date/Time:</Label>

                        <XC:OSDateTimePicker VerticalAlignment="Center" Grid.Column="1" Grid.Row="3" Margin="2" 
                                             Value="{Binding Path=LastRunDate, NotifyOnTargetUpdated=True,Mode=TwoWay,NotifyOnSourceUpdated=True}" 
                                             Format="0" FormatString="g" Watermark="" Visibility="{Binding ShowDates,Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        
                        <Label VerticalAlignment="Center" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Right" Foreground="White" Visibility="{Binding ShowDates,Converter={StaticResource BooleanToVisibilityConverter}}">Registration End Date/Time:</Label>
                        
                        <XC:OSDateTimePicker VerticalAlignment="Center" Grid.Column="1" Grid.Row="4" Margin="2" 
                                             Value="{Binding Path=EndRunDate, NotifyOnTargetUpdated=True,Mode=TwoWay,NotifyOnSourceUpdated=True}" 
                                             Format="0" FormatString="g" Watermark="" Visibility="{Binding ShowDates,Converter={StaticResource BooleanToVisibilityConverter}}"/>

                        <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2" Grid.Row="5" VerticalAlignment="Center" Margin="2" HorizontalAlignment="Center">
                            <Button Name="TestButton" Margin="0,0,5,0" IsEnabled="{Binding IsEnabled}"  Command="{Binding TestCommand}">Test Connection</Button>
                            <Button Name="SaveButton" Width="80" Margin="0,0,5,0" IsEnabled="{Binding IsEnabled}" Command="{Binding SaveCommand}" Click="Button_Click">Save</Button>
                            <Button Name="CancelButton" Width="80" IsCancel="True" Click="Button_Click">Close</Button>
                        </StackPanel>
                        <TextBlock Text="{Binding Version,FallbackValue=1.0.0.0}" Grid.Column="1" Grid.Row="5" VerticalAlignment="Bottom" HorizontalAlignment="Right" FontStyle="Italic" FontSize="10" Foreground="White" Margin="0,0,0,1" />
                    </Grid>
                </Border>
                
            </Grid>
        </Border>
    </Border>

</Window>
